<%-- 
    Document   : conexionCajero
    Created on : 29-oct-2011, 11:45:37
    Author     : Yojugracu
--%>


<%@page import="java.sql.ResultSet"%>
<%@page import="Monetario.ConexionMysql"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<jsp:useBean id = "conectar" scope = "application" class= "Monetario.ManipulacionMysql"/>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<%
    int id = Integer.valueOf(request.getParameter("idCuenta"));
    int saldoinicial;
    int saldofinal;
    float valor = Float.valueOf(request.getParameter("monto"));
    int idCajero = Integer.valueOf(request.getParameter("cajero"));
    int idTerminal = Integer.valueOf(request.getParameter("terminal"));
    int idDocumento = Integer.valueOf(request.getParameter("documento"));
    int tipoTrans = Integer.valueOf(request.getParameter("tipo"));
    ConexionMysql conex=new ConexionMysql();
        if(tipoTrans == 1){
            conex.GenerarSentencia("call MAKE_DEPOSITO("+id+", NOW(), @saldoi, "+valor+", @saldof, "+idCajero+", "+idTerminal+", "+idDocumento+", @resultado);");
       }else{
            conex.GenerarSentencia("call MAKE_RETIRO("+id+", NOW(), @saldoi, "+valor+", @saldof, "+idCajero+", "+idTerminal+", "+idDocumento+", @resultado);");
        }
    ResultSet rs=conex.GenerarR("SELECT @saldoi;");
    //saldoinicial = Integer.valueOf(rs.getString(1));
    request.setAttribute("saldoi", rs.getFloat(1));
    rs = conex.GenerarR("SELECT @saldof;");
    //saldofinal = Integer.valueOf(rs.getString(1));
    request.setAttribute("saldof", rs.getFloat(1));
    response.sendRedirect("cajero1.jsp");
        %>
